﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class courses_tools_viewer : System.Web.UI.Page, ITrainingCourseView
{
    private TrainingCoursePresenter presenter;

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        presenter = new TrainingCoursePresenter(this);
    }

    protected void Page_Load(object sender, EventArgs e)
    {

        presenter.Initialize();

    }
    protected void ExitCourseLinkButton_Click(object sender, EventArgs e)
    {
        presenter.Exit();
    }
    protected void NextSlideLinkButton_Click(object sender, EventArgs e)
    {
        presenter.NextSlide();
    }

    #region ITrainingCourseView Members

    public string CourseTitle
    {
        set
        {
            CourseTitleLabel.Text = value;
        }
    }

    public int CurrentSlide
    {
        get
        {
            return (int) ViewState["CurrentSlide"];
        }
        set
        {
            ViewState["CurrentSlide"] = value;
        }
    }

    public TrainingCourse TrainingCourse
    {
        get
        {
            return ViewState["CurrentCourse"] as TrainingCourse;
        }
        set
        {
            ViewState["CurrentCourse"] = value;
            CourseOutlineRepeater.DataSource = value;
            CourseOutlineRepeater.DataBind();
        }
    }

    public TrainingCourse CourseTableOfContents
    {
        set 
        {
            CourseOutlineRepeater.DataSource = value;
            CourseOutlineRepeater.DataBind();
        }
    }

    public string CurrentSlideURL
    {
        get
        {
            return SlideView.Attributes["src"];
        }
        set
        {
            SlideView.Attributes["src"] = Page.ResolveUrl(value);
        }
    }

    #endregion

    protected void PreviousSlideLinkButton_Click(object sender, EventArgs e)
    {
        presenter.PreviousSlide();
    }
    protected void FirstSlideLinkButton_Click(object sender, EventArgs e)
    {
        presenter.FirstSlide();
    }
}
